﻿using System;

using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Silvermoon.Interfaces;

namespace Silvermoon.Shapes
{
    /// <summary>
    /// Abstract Shape that has a color property.
    /// </summary>
    public abstract class ColorShape : BackgroundShapeBase, IColor
    {
        private Color color;

        public ColorShape()
            : base()
        {
            color = GetDefaultColor();
        }


        public ColorShape(Color color)
            : base()
        {
            this.color = color;
        }

        public override Color Color
        {
            get { return color; }
            set
            {
                if (color != value)
                {
                    color = value;
                    InvalidateColor();
                }
            }
        }


        protected override Color ColorCore { get { return color; } }

        protected override RenderStyle StyleCore { get { return RenderStyle.Metalic; } }

        /// <summary>
        /// Gets the default color with which the ColorShape will be initialized.
        /// </summary>
        /// <returns></returns>
        protected virtual Color GetDefaultColor()
        {
            return Color.White;
        }

        protected virtual void InvalidateColor()
        {
            Invalidate();
            DisposeBuffers();
          //  PreLoad();
        }
    }
}
